﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bob.FormG
{
public partial class FormX : Form {
    public FormX() {
        InitializeComponent();
        textBoxDir.Text = "";
        if (ClassPluginMan.instance()!=null) {
            textBoxDir.Text = ClassPluginMan.instance().danmuPath;
        }
    }

    private void label1_Click(object sender, EventArgs e) {
    }

    private void labeldir_Click(object sender, EventArgs e) {
    }

    private void button1_Click(object sender, EventArgs e) {
        FolderBrowserDialog dialog = new FolderBrowserDialog();
        dialog.Description = "请选择文件路径";
        if (dialog.ShowDialog() == DialogResult.OK) {
            string foldPath = dialog.SelectedPath;
            if (!foldPath.EndsWith("\\")) {
                foldPath += '\\';
            }
            MessageBox.Show("已选择文件夹:" + foldPath, "选择文件夹提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            textBoxDir.Text = foldPath;
            ClassPluginMan.instance().danmuPath = foldPath;
        }
    }

    private void FormX_DragDrop(object sender, DragEventArgs e) {
        string[] filename = (string[])e.Data.GetData(DataFormats.FileDrop);
        string foldPath = filename[0];
        if (Directory.Exists(foldPath)) {
            if (!foldPath.EndsWith("\\")) {
                foldPath += '\\';
            }
        }
        else {
            if (!foldPath.EndsWith("\\")) {
                int last = foldPath.LastIndexOf('\\');
                foldPath = foldPath.Substring(0, last + 1);
            }
        }
        textBoxDir.Text = foldPath;
        ClassPluginMan.instance().danmuPath = foldPath;
    }

    private void FormX_DragEnter(object sender, DragEventArgs e) {
        if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
            e.Effect = DragDropEffects.All;
        }
    }
}
}
